extends Line2D

@onready var audio_instance:AudioEffectSpectrumAnalyzerInstance
@onready var lines_up=[]
const FILL_GRADIENT = preload("uid://1u7ie6ce4yh8")

var radus:int = 50
var line_cnt:int = 48
var spacing:int = 0

func add_up_lines():
	for i in points.size():
		var new_line_1=Line2D.new()
		add_child(new_line_1)
		lines_up.append(new_line_1)
		new_line_1.add_point(points[i])
		new_line_1.add_point(points[i])
func _ready():
	for i in line_cnt:
		add_point(Vector2(i*16-24*16,0.0))
	audio_instance=AudioServer.get_bus_effect_instance(1,0)
	add_up_lines()
func _process(delta:float):
	for i in points.size():
		var temp_y=(audio_instance.get_magnitude_for_frequency_range(60*i,60*(i+1))*1000).y
		#lines_up[i].points[1].y=lerp(lines_up[i].points[1].y,temp_y,0.1)
		if temp_y>20:
			temp_y = (temp_y-20)*0.3+20
		var lenn = lerp(lines_up[i].points[1].y,temp_y,25*delta)
		lines_up[i].points[1] =lines_up[i].points[0]+Vector2(0,1)*lenn
